package com.xingkeduo.business.operation.service;

import com.xingkeduo.dao.database.DatabaseAccessObject;
import com.xingkeduo.pojo.query.CountryQuery;
import com.xingkeduo.pojo.table.CountryTable;
import com.xingkeduo.util.tool.CommonUtil;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 文件概述
 *
 * @author wangxilong <wangxilong@xingkeduo.com>
 * @version id:v0.1 ${date}${time}
 * @package BeautyOS
 * @copyright Copyright (c) XKD 2019
 */
@Component
public class CountryService {
    private static final String NAMESPACE = CountryTable.class.getSimpleName();

    @Resource(name = "mysqlOperationDao")
    private DatabaseAccessObject<CountryTable, CountryQuery> dao;

    //查询一条
    public CountryTable selectById(long id) throws Throwable {
        CountryTable countryTable = dao.select(NAMESPACE, id);
        if (countryTable!=null && !CommonUtil.isEmpty(countryTable.getName()))
            return countryTable;
        return null;
    }

    //查询多条
    public List<CountryTable> selectLists(CountryQuery countryQuery) throws Throwable {
        List<CountryTable> countryTableList = dao.select(NAMESPACE, countryQuery);
        if (!CommonUtil.isEmpty(countryTableList))
            return countryTableList;
        return null;
    }



}
